// ViewFav.cpp : implementation file
//

#include "stdafx.h"
#include "Lottery2.h"
#include "ViewFav.h"

#define IDC_REPORT		4001
#define H_BAR		24

// CViewFav

IMPLEMENT_DYNCREATE(CViewFav, CView)

CViewFav::CViewFav()
{

}

CViewFav::~CViewFav()
{
}

BEGIN_MESSAGE_MAP(CViewFav, CView)
	ON_WM_NCCALCSIZE()
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_ERASEBKGND()
END_MESSAGE_MAP()


// CViewFav drawing

void CViewFav::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}


// CViewFav diagnostics

#ifdef _DEBUG
void CViewFav::AssertValid() const
{
	CView::AssertValid();
}

#ifndef _WIN32_WCE
void CViewFav::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif
#endif //_DEBUG


// CViewFav message handlers

void CViewFav::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
	// TODO: Add your message handler code here and/or call default

	lpncsp->rgrc[0].left-=1;
	lpncsp->rgrc[0].right+=1;
	lpncsp->rgrc[0].top-=1;
	lpncsp->rgrc[0].bottom+=1;

	CView::OnNcCalcSize(bCalcValidRects, lpncsp);
}

int CViewFav::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here

	m_wndToolbar.CreateToolBar(WS_CHILD|WS_VISIBLE,this);
	m_wndToolbar.LoadToolBar(IDR_BAR_FAV);
	m_wndToolbar.SetFlags(xtpFlagStretched,xtpFlagFloating);
	//m_wndToolbar.SetDefaultButtonStyle(xtpButtonIconAndCaptionBelow);
	//m_wndToolbar.SetFlags(xtpFlagRightAlign|xtpFlagManualUpdate);
	m_wndToolbar.SetCloseable(FALSE);
	m_wndToolbar.SetShowGripper(FALSE);
	// 	m_wndToolbar.SetIconSize(CSize(H_BAR,H_BAR));
	//
	m_wndReport.Create(WS_CHILD|WS_VISIBLE,CXTPEmptyRect(),this,IDC_REPORT);
	m_wndReport.ShowHeader(FALSE);


	return 0;
}

void CViewFav::OnSize(UINT nType, int cx, int cy)
{
	CView::OnSize(nType, cx, cy);

	// TODO: Add your message handler code here

	CSize sz(0);
	if (m_wndToolbar.GetSafeHwnd())
	{
		sz = m_wndToolbar.CalcDockingLayout(cx, LM_HORZDOCK|LM_HORZ | LM_COMMIT);
		m_wndToolbar.MoveWindow(0, 0, cx, sz.cy);
		m_wndToolbar.Invalidate(FALSE);
	}
	if (m_wndReport.GetSafeHwnd())
		m_wndReport.MoveWindow(0,sz.cy,cx,cy-sz.cy);
}
BOOL CViewFav::OnEraseBkgnd(CDC* pDC)
{
	// TODO: Add your message handler code here and/or call default

	return TRUE/*CView::OnEraseBkgnd(pDC)*/;
}